var app = getApp();
var util = require('../../utils/util')
    //Page Object
Page({
    data: {
        systemInfo: app.systemInfo,
        user: null,
        userinfo: null
    },
    gotoOpenVip: function(e) {
        wx.navigateTo({
            url: '/packageA/pages/purchaseVip/index'
        });
    },
    gotoEntry: function(e) {
        wx.navigateTo({
            url: '/packageA/pages/EntryRecord/index'
        });
    },
    gotoRecords: function(e) {
        wx.navigateTo({
            url: '/packageA/pages/RecordsConsumption/index'
        });
    },
    getCard() {
        util.postRequest('FinanceManage/rest/queryPointInfo.do', { openId: app.openId }, function(res) {
            console.log(res)
        })
    },
    getVipInfo() {
        let _self = this
        util.postRequest('/FinanceManage/rest/memberDetail.do', { openId: app.openId }, function(res) {
            console.log(res)
            _self.setData({
                userinfo: res.bean
            })
        })
    },
    card() {
        let _self = this
        util.postRequest('FinanceManage/rest/signInPoint.do', { openId: app.openId }, function(res) {
            console.log(res)
            if (res.errorcode == 1) {
                let data = {
                    title: '签到提示',
                    text: '成功签到！获得' + res.point + '积分！'
                }
                util.alertModel(data, function(res) {
                    console.log(res)
                    this.getCard()
                    this.getVipInfo()
                })
            } else {
                let data = {
                    title: '签到提示',
                    text: res.message
                }
                util.alertModel(data, function(res) {
                    console.log(res)
                    _self.getCard()
                    _self.getVipInfo()
                })
            }
        })
    },
    //options(Object)
    onShow: function(options) {
        console.log(app)
        this.setData({
            user: app.userInfo
        })
        console.log(this.data.user)
        this.getCard()
        this.getVipInfo()
    },
    onReady: function() {

    },
    // onShow: function() {

    // },
    onHide: function() {

    },
    onUnload: function() {

    },
    onPullDownRefresh: function() {

    },
    onReachBottom: function() {

    },
    onShareAppMessage: function() {

    },
    onPageScroll: function() {

    },
    //item(index,pagePath,text)
    onTabItemTap: function(item) {

    }
});